package com.kust.eduService.controller;


import com.kust.commomUtils.Result;
import com.kust.eduService.entity.subject.OneSubject;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.kust.eduservice.service.EduSubjectService;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-06-22
 */
@Api("上传用户")
@RestController
@RequestMapping("/eduService/edu-subject")
public class EduSubjectController {

    @Autowired
    private EduSubjectService service;

    //添加课程分类
    //获取上传过来文件，把文件内容读取出来
    @PostMapping("/addSubject")
    public Result addSubject( MultipartFile file){
        //上传过来excel文件
        System.out.println(file.getName());
        service.saveSubject(file,service);
        return Result.ok();
    }

    //课程分类列表（树形）
    @GetMapping("/getAllSubject")
    public Result getAllSubject(){
        List<OneSubject> list=service.getAllOneTwoSubject();
        return Result.ok().data("list",list);
    }
}

